package lia.util;

/**
 * read file config
 * 
 * @author F.H Dragon(wenlong.meng@gmail.com)
 * @version 1.0 at 2011/08.05
 * @since 1.0
 */
public class FileReaderConfig {
	
	//local variables
	/**
	 * file path
	 */
	private String path;
	/**
	 * file type: xml, txt and so on.
	 */
	private FileType fileType;
	/**
	 * field Separator
	 */
	private String fieldSeparator;
	/**
	 * field Separator
	 */
	private String docSeparator;
	
	/**
	 * constructor FileReaderConfig instance
	 * 
	 * @param path
	 */
	public FileReaderConfig(String path){
		this.path = path;
	}
	
	/**
	 * @return the path
	 */
	public String getPath() {
		return path;
	}
	/**
	 * @param path the path to set
	 */
	public void setPath(String path) {
		this.path = path;
	}

	/**
	 * @return the fileType
	 */
	public FileType getFileType() {
		if(this.fileType == null){
			if(this.path.endsWith(".txt")){
				this.fileType = FileType.txt;
			}else if(this.path.endsWith(".xml")){
				this.fileType = FileType.xml;
			}
		}
		return fileType;
	}
	/**
	 * @param fileType the fileType to set
	 */
	public void setFileType(FileType fileType) {
		this.fileType = fileType;
	}

	/**
	 * @return the fieldSeparator
	 */
	public String getFieldSeparator() {
		return fieldSeparator;
	}
	/**
	 * @param fieldSeparator the fieldSeparator to set
	 */
	public void setFieldSeparator(String fieldSeparator) {
		this.fieldSeparator = fieldSeparator;
	}

	/**
	 * @return the docSeparator
	 */
	public String getDocSeparator() {
		return docSeparator;
	}
	/**
	 * @param docSeparator the docSeparator to set
	 */
	public void setDocSeparator(String docSeparator) {
		this.docSeparator = docSeparator;
	}

	/**
	 * defined file type
	 * 
	 * @author F.H Dragon(wenlong.meng@gmail.com)
	 * @version 1.0 at 2011/08/05
	 * @since 1.0
	 */
	public static enum FileType{
		xml,
		txt
	}

	/**
	 * (non-Javadoc)
	 * @see java.lang.Object#toString()
	 */
	@Override
	public String toString() {
		return "FileReaderConfig ["
				+ (path != null ? "path=" + path + ", " : "")
				+ (fileType != null ? "fileType=" + fileType + ", " : "")
				+ (fieldSeparator != null ? "fieldSeparator=" + fieldSeparator
						+ ", " : "")
				+ (docSeparator != null ? "docSeparator=" + docSeparator : "")
				+ "]";
	}

}
